﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace rkServer
{
    public partial class FrmServerSettings : Form
    {
        public string GameName { get; set; }
        public int Seed { get; set; }
        public int Port { get; set; }

        public FrmServerSettings()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtGameName.Text))
            {
                MessageBox.Show("Please Enter Game Name");
                return;
            }
            int _seed;
            int _port;
            if (int.TryParse(txtSeed.Text, out _seed) && int.TryParse(txtPort.Text, out _port))
            {
                this.Seed = _seed;
                this.Port = _port;
                this.GameName = txtGameName.Text;
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageBox.Show("Invalid Port number/ Seed");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Random _rnd = new Random();
            txtSeed.Text = _rnd.Next(99999).ToString();
        }
    }
}
